Fix appearance model: late-seed dark companion after Realize#26
Merged
Conversation
ensureAppearanceInitialised seeds the dark preference by looking up the current palette's companion. But frontends typically call dasher_set_system_appearance from their .onAppear handler, which fires BEFORE Realize() (and before ColorIO is populated). At that point the companion lookup fails, darkPalette stays empty, and once appearanceLoaded is set to true the seed is never retried. Result: system appearance changes never flip the palette — resolveAppearance picks an empty darkPalette, falls back to an empty lightPalette, and returns without doing anything. Fix: add a late-seed check in resolveAppearance. If darkPalette is empty but lightPalette is set and ColorIO is now available, retry the companion lookup. This runs on every resolveAppearance call, so once Realize completes and the next system-appearance change (or mode change) arrives, the companion is found and dark mode works. Signed-off-by: will wade <willwade@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
System appearance changes don't flip the palette — the canvas stays on the same colour scheme regardless of iOS light/dark setting.
Root cause
ensureAppearanceInitialisedseedsdarkPaletteby looking up the current palette's companion. But frontends calldasher_set_system_appearancefrom their.onAppearhandler, which fires before Realize() — before ColorIO is populated. At that point the companion lookup fails,darkPalettestays empty, and onceappearanceLoaded = truethe seed is never retried.resolveAppearancethen picks an emptydarkPalette, falls back tolightPalette(or also empty), and returns without doing anything.Timeline:
Fix
Add a late-seed check in
resolveAppearance: ifdarkPaletteis empty butlightPaletteis set and ColorIO is now available, retry the companion lookup. Runs on every call, so once Realize completes and the next system/mode change arrives, the companion is found.11 insertions, no deletions. No API change.